import 'package:flutter/material.dart';
import 'dart:convert';

class FavoritePage extends StatefulWidget {
  //接受传递的参数
  final arguments;
  //FavoritePage({Key key, this.arguments}) : super(key: key);
  FavoritePage({this.arguments});
  @override
  _FavoritePage createState() => _FavoritePage();
}

class _FavoritePage extends State<FavoritePage> {
  String name;
  int count = 0;

  void add() {
    setState(() {
      count++;
    });
  }

  @override
  void initState() {
    super.initState();
    print('FavoritePage initState');
    Map argObjMap = widget.arguments;
    this.name = argObjMap['name'];
    //print(widget.arguments.runtimeType.toString());
    print(this.name);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
          //导航栏
          title: Text("收藏")),
      body: Center(
          child: Column(children: <Widget>[
        Text("获取传递参数:$name", style: TextStyle(fontSize: 30)),
        Text('favoritePage没有缓存: $count 重新进来数据将会丢失', style: TextStyle(fontSize: 30))
      ])),
      floatingActionButton: FloatingActionButton(
        heroTag: 'favoriteFloatingActionButton',
        onPressed: add,
        child: Icon(Icons.add),
      ),
    );
  }
}
